import protocol
import time

dl = protocol.Datalink("/dev/ttyUSB0")

msg = list("abcdefghijklmnop" )

runs = 20

hz = [0.0 for i in range(runs)]

start_time = time.time()
for i in range(runs):
    now = time.time()
    dl.send(msg)
    resp = dl.receive()
    latency = time.time() - now
    hz[i] = 1.0/latency
end_time = time.time()
    
print "Average Hz %.2f"%(sum(hz) / runs)
print "Time for %d runs was %.2f"%(runs, end_time - start_time)
